package application;

import java.util.ArrayList;

public class strStack {

    ArrayList a;
    int currentItem;

    public strStack() {
        a = new ArrayList();
        currentItem = 0;
    }

    public void push(Object o) {
        a.add(o);
        currentItem++;
    }

    public Object pop() {
        Object result = (!a.isEmpty() ? a.get(--currentItem) : "");
        a.remove(currentItem);
        return result;
    }

    public void showStack() {
        System.out.println(a.toString());
    }

    public boolean isEmpty() {
        if (currentItem == 0) {
            return true;
        }
        return false;
    }

    public int getCurrentItem() {
        return currentItem;
    }

    public Object getLast() {
        return (currentItem < 0 ? a.get(currentItem) : "");
    }

    public String devaststeStack() {
        String result = "";
        for (int i = currentItem - 1; i > 0; i--) {
            result += a.get(i);
        }
        return result;
    }
    public void remLast() {
        a.remove(currentItem);
    }
    public int size () {
        return currentItem;
    }
}
